package com.luo.controller;

import com.luo.pojo.Results;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

@RestController
@Slf4j
public class UploadController {
    @PostMapping("/upload")
    public Results upload(MultipartFile image) throws IOException {
        log.info("上传成功{}", image);
        UUID uuid = UUID.randomUUID();
        String filename = uuid + "-" + image.getOriginalFilename();
        image.transferTo(new File("D:\\"+  filename));
        return Results.success();
    }

}
